package com.example.microservice.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Created by sun on 2018/11/9.
 * 配置swagger2
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {


    /**
     * 创建swagger对象:
     *
     * @return
     */
    @Bean
    public Docket mapRestApi() {
        return new Docket(DocumentationType.SWAGGER_2).groupName("地图坐标转化APIs")
                .apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.basePackage("com.example.microservice.http.controller.server.map"))
                .paths(PathSelectors.any())
                .build();
    }


    /**
     * 设置api信息
     * title:swagger题目
     * description:描述
     * cotact:创建者
     *
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("微服务API")
                .description("springboot框架小服务")
                .contact(new Contact("cajianerguo",null ,"2337586134@qq.com"))
                .version("1.0")
                .build();
    }


}
